<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据双向绑定不用柯里化的实现</title>
</head>
<body>
  <div id="test"></div>

  <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <script src="https://cdn.staticfile.org/prop-types/15.6.1/prop-types.js"></script>

  <script type="text/babel">
    class Demo extends React.Component {
      state = {
        username: '',
        password: ''
      }
      handleSubmit = (event) => {
        event.preventDefault()
      }
       
      saveFormData = (dataType, value) => {
        this.setState = {
          [dataType]: value
        }
        console.log(dataType, value)
      }
      render() {
        return (
          <form onSubmit={ this.handleSubmit }>
            用户名：<input type="text" name="username" onChange={ event => this.saveFormData('username', event.target.value) } />
            密码：<input type="paasword" name="paasword" onChange={ event => this.saveFormData('paasword', event.target.value) } />
            <button>登录</button>
          </form>
        )
      }
    }
    ReactDOM.render(<Demo />, document.getElementById('test'))
  </script>
</body>
</html>